package cn.edu.bs.config;

import cn.edu.bs.web.interceptor.permission.PermissionInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author bs
 */
@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

    private final PermissionInterceptor permissionInterceptor;

    @Autowired
    public WebAppConfigurer(PermissionInterceptor permissionInterceptor) {
        this.permissionInterceptor = permissionInterceptor;
    }

    /**
     * 添加拦截器链
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(permissionInterceptor)
                .addPathPatterns("/admin/**");
    }

}
